<?php
use yii\helpers\Url;
$this->title = '昊祥科技-会员中心';

$signPackage = \app\components\Jssdk::getSignPackage();
$session = Yii::$app->session;
$coord =  $session->get('positioning');
?>
<script>
var signPackage = <?= json_encode($signPackage) ?>;
var positioningUrl = "<?=Url::to(['member/positioning'])?>";
    console.log(signPackage);
var wxPayUrl = "<?= Url::to(['member/wechat-pay'])?>";
var timestamp = '<?= time()?>'
var pointsUrl = '<?= Url::to(['wechat-pay/index'])?>'
</script>

<h2>这是一个测试的会员中心</h2>

<ul class="list-inline">
    <a href="<?= Url::to(['member/profile']); ?>">个人资料</a>
    <a href="<?= Url::to(['member/card-detail']); ?>">会员卡介绍</a>
    <a href="<?= Url::to(['member/points-detail']); ?>">积分页面</a>
    <a href="<?= Url::to(['wechat-member-card/index']); ?>">原生会员卡</a>
</ul>
<div>
	昵称: <?= $userName?><br/>
	拥有积分: <?= $points?>
</div>
<form action="<?= Url::to(['member/wechat-pay'])?>" method="post">
	请输入金额 : <input type="text" name="total_fee" value="">
	</br>10积分可抵扣1分钱:<input type="checkbox" name="points" value="10">
    <input name="_csrf" type="hidden" id="_csrf" value="<?= Yii::$app->request->csrfToken ?>">
	</br><button type="submit">提交</button>
</form>
<div style="margin-top:30px;margin-bottom:30px;text-align:center;">
    <a id="gettestcard" href="#" style="border:1px solid #333;padding:6px;text-decoration:none;">领取微信原生会员卡</a>
</div>
<div>
    <h4>微信资料</h4>

</div>

<div>
    <h4>用户信息</h4>
    <pre>
    </pre>
</div>
<a href="###" onclick="positioning()">点击定位</a>
<!-- <script src="//res.wx.qq.com/open/js/jweixin-1.2.0.js"></script> -->
<?php

$this->registerJsFile('//res.wx.qq.com/open/js/jweixin-1.2.0.js', ['depends' => [\app\assets\HxkjAsset::className()]]);

$this->registerJsFile('@web/hxkj/js/jssdk.js', ['depends' => [\app\assets\HxkjAsset::className()]]);

?>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
    <style type="text/css">
        body, html {width: 100%;height: 100%;margin:0;font-family:"微软雅黑";}
        #allmap{width:100%;height:500px;}
        p{margin-left:5px; font-size:14px;}
        label {
            /* display: inline-block; */
            max-width: 50px;
            /* margin-bottom: 5px; */
            /* font-weight: bold; */
        }
    </style>
    <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=ZPBWB5yWkiKVGNOblE9qp1zqq43zU8l6"></script>
    <title>添加多个标注点</title>
</head>
<body>
<div id="allmap"></div>
</body>
<script type="text/javascript">
    // 百度地图API功能
    var map = new BMap.Map("allmap");
    var point = new BMap.Point(<?php echo  isset($coord)? $coord : "104.06232,30.569874"?>);
    map.centerAndZoom(point, 16);
    map.enableScrollWheelZoom(true);
    // 编写自定义函数,创建标注
    function addMarker(point,content){
        var marker = new BMap.Marker(point);
        map.addOverlay(marker);
        var label = new BMap.Label(content,{offset:new 	   BMap.Size(20,-10)});
        marker.setLabel(label);
    }
    // 起点和终点
    var point1 = new BMap.Point(104.05232,30.559874);
    addMarker(point1,'活动地址');
    var point2 = new BMap.Point(<?php echo  isset($coord)? $coord : "104.06232,30.569874"?>);
    alert(<?php echo  isset($coord)? $coord : "null"?>);
    console.log(point2);
    addMarker(point2,'我的位置');
    alert('距离是：'+(map.getDistance(point1,point2)).toFixed(2)+' 米。');  //获取两点距离,保留小数点后两位
    var polyline = new BMap.Polyline([point1,point2], {strokeColor:"blue", strokeWeight:6, strokeOpacity:0.5});  //定义折线
    map.addOverlay(polyline);     //添加折线到地图上
</script>